package com.recyclerview.demo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.administrator.baseadapter.recyclerview.QuickAdapter;
import com.example.administrator.baseadapter.recyclerview.holder.RecyclerViewHolder;
import com.example.administrator.baseadapter.recyclerview.holder.ViewHolder;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends Activity {

    private RecyclerView mRecyclerView;
    private List<String> mDatas = new ArrayList<>();
    //通用适配器
    private QuickAdapter<String> mQuickAdapter;


    //所有页面都可以用ViewHolder
    private ViewHolder viewHolder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        viewHolder = new ViewHolder(this, getWindow().getDecorView());

        for (int i = 'A'; i < 'z'; i++) {
            mDatas.add((char) i + "");
        }
        mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mQuickAdapter = new QuickAdapter<String>(this, mDatas, R.layout.item_list) {
            @Override
            public void convert(RecyclerViewHolder holder, String s, int position) {
                holder.getViewHolder().setText(R.id.id_item_list_title, s);
            }
        };
        mRecyclerView.setAdapter(mQuickAdapter);

        //显示数据
        viewHolder.setText(R.id.id_text, "页面显示数据");
    }
}
